﻿/*标签式参数的实现
 * 内部使用
 * Created By WangZg
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace Octopus.Logging.ExtendibleSupport
{
    internal class VolatileParamParser : IVolatileConfigParser
    {
        private IDictionary<string,string> paramList ;

        public VolatileParamParser() 
        {
            paramList = new Dictionary<string, string>();
        }

        public string ReplaceVolatileConfig(string source)
        {
            if (string.IsNullOrEmpty(source)) { return source; }
            string sValue = source;
            foreach (KeyValuePair<string, string> item in paramList)
            {
                if (string.IsNullOrEmpty(item.Key)) { continue; }

                sValue = sValue.Replace(item.Key, item.Value);
            }
            return sValue;
        }

        public void SetVolatileRule(string key, string value)
        {
            paramList[key] = value;
        }
    }
}
